//
//  UIBarButtonItem+Item.m
//  BuDeJie
//
//  Created by Sem on 2018/6/26.
//  Copyright © 2018年 SEM. All rights reserved.
//

#import "UIBarButtonItem+Item.h"

@implementation UIBarButtonItem (Item)
+(UIBarButtonItem *)ItmeWithImage:(UIImage *)image withHigthImage:(UIImage *)higthImage addTarget:(nullable id)target action:(SEL)action{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:image forState:UIControlStateNormal];
    [btn setImage:higthImage forState:UIControlStateHighlighted];
    [btn sizeToFit];
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    UIView *view =[[UIView alloc]initWithFrame:btn.bounds];
    [view addSubview:btn];
    return [[UIBarButtonItem  alloc]initWithCustomView:view];
}
+(UIBarButtonItem *)ItmeWithImage:(UIImage *)image withSelImage:(UIImage *)selImage addTarget:(nullable id)target action:(SEL)action{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:image forState:UIControlStateNormal];
    [btn setImage:selImage forState:UIControlStateSelected];
    [btn sizeToFit];
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    UIView *view =[[UIView alloc]initWithFrame:btn.bounds];
    [view addSubview:btn];
    return [[UIBarButtonItem  alloc]initWithCustomView:view];
}
@end
